
//
//  CarlistCellMode.m
//  CarTown
//
//  Created by xionghao on 15/8/24.
//  Copyright (c) 2015年 熊浩. All rights reserved.
//

#import "CarlistCellMode.h"
#define defluatrowheight 92

@implementation CarlistCellMode
-(void)setCardmode:(CarDetailmodel *)cardmode{
    _cardmode=cardmode;
    CGFloat textwith;
    
    
    if (XHScreenwidth==320) {
       textwith=148;
        
    }else{
        textwith=198;
    }

    if ([_cardmode.car_configure isEqualToString:@""]&&![_cardmode.car_source_type isEqualToString:@"中规"]) {
        self.rowheight=defluatrowheight+2*10;
        return;
    }
    
    NSDictionary *attribute = @{NSFontAttributeName: [UIFont systemFontOfSize:12]};
    
    CGSize labelSize = [_cardmode.car_configure boundingRectWithSize:CGSizeMake(textwith, 0) options: NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attribute context:nil].size;
    CGFloat lableheight=labelSize.height;
    if (lableheight>28) {
        lableheight=28;
    }
    NSString *pricestr;
    if ([_cardmode.car_source_type isEqualToString:@"中规"]) {
        float xia=[[NSString removeZero:_cardmode.sprice] floatValue] - [_cardmode.sysprice floatValue];
        NSString *strxia=
        [NSString removeZero:[NSString stringWithFormat:@"%.02f",xia]]
        ;
        if (xia!=0) {
            pricestr=[NSString stringWithFormat:@"指导价：%@万/下%@万",[NSString removeZero:_cardmode.sprice],strxia];
        }else{
            pricestr=[NSString stringWithFormat:@"指导价：%@万",[NSString removeZero:_cardmode.sprice]];
        }
        
    }
 
    
   CGSize pricesize = [pricestr boundingRectWithSize:CGSizeMake(MAXFLOAT, 0) options: NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attribute context:nil].size;
    CGFloat height=MAX(lableheight, pricesize.height);
    self.rowheight=height+defluatrowheight+2*10;
    
}
@end
